<?php

namespace App\Http\Requests\Backend;

use Illuminate\Foundation\Http\FormRequest;

class ProjectTypesRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            // CREATE
            case 'POST':
                return [
                    'project_type_name' => 'required',
                    'project_type_desc' => 'required',
                    'is_enable' => 'required',
                ];
            case 'PUT':
                return [
                    'id' => 'required',
                    'project_type_name' => 'required',
                    'project_type_desc' => 'required',
                    'is_enable' => 'required',
                ];
            default:
                return [];
        }

    }

    public function messages()
    {
        return [
            'id.required' => '主键不能为空！',
            'link_name.required' => '请输入项目类型名称！',
            'link_url.required' => '请输入项目类型描述！',
            'is_enable.required' => '请选择启用状态！',
        ];
    }
}
